﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlServerCe;

namespace SqlCEUpgrade
{
    class Program
    {
        static void Main(string[] args)
        {
            //OracleTest.TestOracle();
            SqliteTest.Test();
            //PropertyGenerator.Generate();
            //string connStringCI = @"Persist Security Info = False; Data Source ='D:\PProj\logistic\logistic.sdf'; Password = 'abc123123'; File Mode = 'shared read';Max Database Size = 256; Max Buffer Size = 1024";
            //string connStringTo = @"Persist Security Info = False; Data Source ='D:\PProj\logistic\logistic4.0.sdf'; Password = 'abc123123'; File Mode = 'shared read';Max Database Size = 256; Max Buffer Size = 1024";
            //UpgradeDatabase(connStringCI, connStringTo);
            //TestDataBase(connStringTo);
            // Set "Case Sensitive" to true to change the collation from CI to CS.
            //string connStringCS = "Data Source= Northwind.sdf; LCID= 1033; Case Sensitive=true";
            //"Persist Security Info = False; Data Source ='Northwind.sdf'; Password = 'abc123123'; File Mode = 'shared read';Max Database Size = 256; Max Buffer Size = 1024"
            //UpgradeDatabase(connStringCI, connStringCS);
        }

        /// <summary>
        /// Demonstrates how to upgrade a database with case sensitivity.
        /// </summary>
        public static void UpgradeDatabase(String src,String des)
        {
            SqlCeEngine engine = new SqlCeEngine(src);

            // The collation of the database will be case sensitive because of 
            // the new connection string used by the Upgrade method.                
            engine.Upgrade(des);
        }

        public static void TestDataBase(String connectString)
        {
            SqlCeConnection conn = null;
            conn = new SqlCeConnection(connectString);
            conn.Open();

            //Retrieve the connection string information - notice the 'Case Sensitive' value.
            List<KeyValuePair<string, string>> dbinfo = conn.GetDatabaseInfo();

            Console.WriteLine("\nGetDatabaseInfo() results:");

            foreach (KeyValuePair<string, string> kvp in dbinfo)
            {
                Console.WriteLine(kvp);
            }
        }
    }
}
